package com.luck.easyfoodbatch.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;

import com.luck.easyfoodbatch.R;
import com.luck.easyfoodbatch.adapter.Category_adapter;
import com.luck.easyfoodbatch.entity.Categorys;
import com.luck.easyfoodbatch.entity.Type;

import java.util.List;

/**
 * Created by Administrator on 2017/5/3.
 */

public class CategoryShopFragment extends Fragment {
    //    private ArrayList<CategoryBean.DataBean.CategoryItem> list;
    private List<Categorys.DataBean.GoodsBean> list;
    private Categorys.DataBean mDataBean;
    private GridView listView;
    private Category_adapter adapter;
    private Type type;
    private String typeName;
    private TextView tvTtitle;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(getContext(), R.layout.categroy_shop_fragment, null);
        listView = (GridView) view.findViewById(R.id.gv_shop_view);
        tvTtitle = (TextView) view.findViewById(R.id.tv_title);
        typeName = getArguments().getString("typeName");
//        list=getArguments().getParcelableArrayList("categoryList");
//        list= (ArrayList<CategoryBean.DataBean.CategoryItem>) getArguments().getSerializable("categoryList");
        mDataBean = (Categorys.DataBean) getArguments().getSerializable("categoryBean");
        list = mDataBean.getGoods();
        tvTtitle.setText(mDataBean.getType());
        adapter = new Category_adapter(getActivity(), list);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                Toast.makeText(getContext(), "你点击了" + list.get(position).getClassname(), Toast.LENGTH_SHORT).show();

            }
        });

        return view;
    }

}
